"""Build dtx library"""
import daos_build

def scons():
    """Execute build"""
    Import('env', 'prereqs')

    env.AppendUnique(LIBPATH=[Dir('.')])

    if not prereqs.server_requested():
        return

    denv = env.Clone()

    prereqs.require(denv, 'argobots', 'protobufc', 'hwloc')
    prereqs.require(denv, 'pmdk', headers_only=True)

    # dtx
    denv.Append(CPPDEFINES=['-DDAOS_PMEM_BUILD'])
    dtx = daos_build.library(denv, 'dtx',
                             ['dtx_srv.c', 'dtx_rpc.c', 'dtx_resync.c',
                              'dtx_common.c', 'dtx_cos.c'], install_off="../..")
    denv.Install('$PREFIX/lib64/daos_srv', dtx)

if __name__ == "SCons.Script":
    scons()
